package junior.db.dao.query;

import junior.db.dao.base.IEntityTypeAssigned;

import java.util.List;

/**
 * @author wubo
 * @date 2024/9/14 16:23
 */
public class TableQuery extends AbstractQuery<ConstantQuery> implements IEntityTypeAssigned {
    private String table;
    
    public TableQuery(String table) {
        this.table = table;
    }
    
    public TableQuery(String table, String alias) {
        this.table = table;
        super.withPrefix(alias);
    }
    
    @Override
    public void setEntityClass(Class<?> entityClass) {
        // do nothing
    }
    
    @Override
    public String getTable() {
        return table;
    }
    
    @Override
    public List<ISelectItem> getFinalSelectFields() {
        if (super.isSelectAll()) {
            return List.of(new SelectExpression("*", null));
        }
        return super.getFinalSelectFields();
    }
}
